package com.fzrskj.cloud.free.core.utils;

import ms.core.tool.StrTool;

/**
 * ProtectionStart.
 *
 * @author zj.
 *         Created on 2018/12/18 0018.
 */
public class ProtectionStartUtils {
    /**
     * 手机数据星号保护
     * @param mobile mobile.
     * @return String
     */
    public static String mobile(String mobile) {
        if (StrTool.isBlankStr(mobile)) {
            return mobile;
        }
        return mobile.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
    }

    /**
     * 身份证星号保护
     * @param idCard
     * @return
     */
    public static String idCard(String idCard) {
        if (StrTool.isBlankStr(idCard)) {
            return idCard;
        }
        return idCard.replaceAll("(\\d{8})\\d{8}(\\d{2})", "$1********$2");
    }
}
